var roleE9S57_Fighter_AH = {

    /** @param {Creep} creep **/
    run: function(creep) {
        //creep.say('AFKclr AH', true);
        
            var enemys = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
            var enemystructure = creep.room.find(FIND_HOSTILE_STRUCTURES, {
                filter: (structure) => (structure.structureType != STRUCTURE_CONTROLLER 
                && structure.structureType != STRUCTURE_RAMPART)
            });
            var enemysin3 = creep.pos.findInRange(FIND_HOSTILE_CREEPS, 3);
            var enemysin2 = creep.pos.findInRange(FIND_HOSTILE_CREEPS, 2);
            var enemystructurein3 = creep.pos.findInRange(FIND_HOSTILE_STRUCTURES, 3);
            var targetfix = creep.pos.findClosestByRange(FIND_MY_CREEPS, {
                filter: function(object) {
                    return object.hits < object.hitsMax;
                }
            });
            if(creep.hits<creep.hitsMax) {
                creep.heal(creep);
            }
         
            if(enemys){
                creep.say('有敌人');
                //creep.rangedAttack(Game.getObjectById('6217c5d43d269162f9026794'));//直接攻击指令 
                if(enemysin3.length<=0){
                    creep.moveTo(enemys, {visualizePathStyle: {stroke: '#00ff00'}});
                }
                else if(enemysin2.length>0){
                    creep.say('太近了');
                    creep.moveTo(Game.flags['E9S58'].pos, {visualizePathStyle: {stroke: '#00ff00'}});
                }
                else{
                    creep.say('射程内');
                    creep.rangedAttack(enemysin3[0]);
                    
                }
            }
            else if(enemystructure.length>0){
                creep.say('有建筑');
                creep.moveTo(enemystructure[0], {visualizePathStyle: {stroke: '#00ff00'}});
                if(enemystructurein3.length>0){
                    creep.say('建筑射程内');
                    creep.rangedAttack(enemystructurein3[0]);
                }
            }
            //手动攻击目标
            // else if(creep.room.find(Game.getObjectById('6215f510f82b57238b4cfe5a'))){
            //     creep.moveTo(Game.getObjectById('6215f510f82b57238b4cfe5a'), {visualizePathStyle: {stroke: '#00ff00'}});
            //     creep.rangedAttack(Game.getObjectById('6215f50e0cec512d7046a933'));
            // }
            else{
                creep.say('去房间');
                //creep.rangedAttack(Game.getObjectById('61832a13fd720f678443e56c'));//直接攻击指令 
                creep.moveTo(Game.flags['E9S57'].pos, {visualizePathStyle: {stroke: '#00ff00'}});
            }
    }
	
};

module.exports = roleE9S57_Fighter_AH;